#include "ThreadPool.h"

V_PDT::ThreadPool::ThreadPool(unsigned num) :m_thread_nums(num), m_stop(false)
{
    for (int i = 0; i < m_thread_nums; ++i) m_threads.push_back(std::make_shared<CThread>(this));
};

void V_PDT::ThreadPool::start()
{
    for (auto& thread : m_threads) thread->start();
}

void V_PDT::ThreadPool::stop()
{
    m_stop.store(true);
    m_wait_con.notify_all();
    for (auto& td : m_threads)
    {
        if (!td->isFinished()) td->wait();
    }
    m_threads.clear();
}
